package com.hsc.www;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication
@Controller
@Configuration
public class Cms8072 {
    public static void main(String[] args) {
        SpringApplication.run(Cms8072.class, args);
    }

    @ResponseBody
    @RequestMapping(value = "news")
    public Object news() {
        String news[] = new String[]{"我和我的祖国", "我是唱作人", "我和我的经纪人", "我爱我家", "我是唱作人第二期", "我的前半生2", "我是歌手", "我们的师父", "我们都要好好的", "我家那闺女"};
        return news;
    }

    @Autowired
    RestTemplate restTemplate;

    @Bean
    public RestTemplate createRestTemplate() {


        RestTemplate restTemplate= new RestTemplate();
        System.out.println(restTemplate.hashCode());
        return  restTemplate;
    }


    @ResponseBody
    @RequestMapping(value = "dbUsers")
    public Object dbUsers() {
        System.out.println(restTemplate.hashCode());

        return restTemplate.getForObject("http://127.0.0.1:8073/dbUsers", Object.class);
    }
}